import 'package:local_coffee/components/rgba.dart';
import 'package:flutter/material.dart';

class ClassifyDesc extends StatelessWidget {
  
  final String name;
  final String desc;

  ClassifyDesc(
    this.name,
    {
      this.desc
    }
  );

  _createNotDesc(String name) {
    return Container(
      child: Row(
        children: <Widget>[
          Text(
            name,
            style: TextStyle(
              fontSize: 12,
              color: RGBA.rgba383838,
              fontWeight: FontWeight.bold
            ),
          ),
          Expanded(
            child: Container(
              margin: EdgeInsets.only(left: 10),
              height: 1,
              color: RGBA.rgbaf2f2f2,
            ),
          )
        ],
      ),
    );
  }

  _create(String name, String desc) {
    return Column(
      children: <Widget>[
        Row(
          children: <Widget>[
            Expanded(
              child: Text(
                name,
                style: TextStyle(
                  fontSize: 12,
                  color: RGBA.rgba383838,
                  fontWeight: FontWeight.bold
                ),
              ),
            )
          ],
        ),
        Row(
          children: <Widget>[
            Text(
              desc,
              style: TextStyle(
                fontSize: 10,
                color: RGBA.rgbaa6a6a6
              ),
            ),
            Expanded(
              child: Container(
                margin: EdgeInsets.only(left: 10),
                height: 1,
                color: RGBA.rgbaf2f2f2,
              ),
            )
          ],
        )
      ],
    );
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(top: 10, bottom: 10),
      child: desc == null ? _createNotDesc(name) : _create(name, desc),
    );
  }
}